function OrderApp(){}
OrderApp.prototype = {
    init:function(){
        //显示订单列表
        OrderApp.prototype.showOrderList();
        //tab切换事件
        $('.mui-mess-ul li').click(function() {
            $('.mui-mess-ul li').removeClass('current');
            $(this).addClass('current');
            $('.mui-mess-content').css('display', 'none').eq($(this).index()).css('display', 'block');
        });
    },
    showOrderList:function(){
        //获取数据
        var filter = OrderApp.prototype.filter;
        var parser = OrderApp.prototype.parser;
        var tpl = $('#orderTpl').html();
        //全部订单
        var apiUrl = '/cooker.php?m=cooker&c=Order&a=getOrderList';
        $.post(apiUrl,{'status':99},function(data){
            //载入模版并创建数据
            parser('allOrder',data,tpl);
        });
        //待支付
        $.post(apiUrl,{'status':2},function(data){
            parser('checkOrder',data,tpl);
        });
        // //待消费
        $.post(apiUrl,{'status':3},function(data){
            parser('useOrder',data,tpl);
        });
        // //待评价
        $.post(apiUrl,{'status':7},function(data){
            parser('commentOrder',data,tpl);
        });
    },
    //订单过滤
    filter:function(data,status){
        var arr = status.split(',');
        var rtn = [];
        for(var i=0;i<data.length;i++){
            for(var j=0;j<arr.length;j++){
                if(data.status == arr[i]){
                    rtn.push(data[i]);
                }
            }
        }
        return rtn;
    },
    //juicer载入数据,混合模板一体化
    parser:function(id,data,tpl,mode){
        //载入模版
        var id = '#'+id;
        if(!tpl){
            if(mode != 'update'){
                tpl = $(id).html();
            }else{
                tpl = $(id).attr('data-tpl');
            }
        }
        var html = juicer(tpl,data);
        $(id).html(html).show().attr('data-tpl',tpl);
    }


};
/**
 * <script id="tpl" type="text/template">
 <ul>
 {@each list as it,index}
 <li>${it.name} (index: ${index})</li>
 {@/each}
 {@each blah as it}
 <li>
 num: ${it.num} <br />
 {@if it.num==3}
 {@each it.inner as it2}
 ${it2.time} <br />
 {@/each}
 {@/if}
 </li>
 {@/each}
 </ul>
 </script>

 Javascript 代码:

 var data = {
    list: [
        {name:' guokai', show: true},
        {name:' benben', show: false},
        {name:' dierbaby', show: true}
    ],
    blah: [
        {num: 1},
        {num: 2},
        {num: 3, inner:[
            {'time': '15:00'},
            {'time': '16:00'},
            {'time': '17:00'},
            {'time': '18:00'}
        ]},
        {num: 4}
    ]
};

 var tpl = document.getElementById('tpl').innerHTML;
 var html = juicer(tpl, data);
 */


